package com.swiftair
{
	import com.swiftair.controller.AuthorizeCommand;
	import com.swiftair.controller.DirectMessagesCommand;
	import com.swiftair.controller.GrantCommand;
	import com.swiftair.controller.HomeTimelineCommand;
	import com.swiftair.controller.MentionsCommand;
	import com.swiftair.controller.StartupCommand;
	import com.swiftair.controller.UpdateListsCommand;
	
	import org.puremvc.as3.patterns.facade.Facade;

    public class ApplicationFacade extends Facade
    {
        /* Notification name constants */

		// application
        public static const STARTUP:String 	= "startup";
        public static const SHUTDOWN:String = "shutdown";

		// Model
		public static const MODEL_AUTHORIZATION_ERROR:String	= "modelAuthorizationError";
		public static const MODEL_ACCESS_GRANTED:String			= "modelAccessGranted";
		public static const MODEL_ACCESS_ERROR:String			= "modelAccessError";
		public static const MODEL_STATUSES_LOADED:String		= "modelStatusesLoaded";
		public static const MODEL_DIRECT_MESSAGES_LOADED:String	= "modelDirectMessagesLoaded";
		// View
		public static const VIEW_MAIN_SCREEN:String				= "viewMainScreen";
		public static const VIEW_SETTINGS_SCREEN:String			= "viewSettingsScreen";
		// Command
		public static const COMMAND_AUTHORIZE:String			= "commandAuthorize";
		public static const COMMAND_GRANT:String				= "commandGrant";
		public static const COMMAND_HOME_TIMELINE:String		= "commandHomeTimeline";
		public static const COMMAND_MENTIONS:String				= "commandMentions";
		public static const COMMAND_DIRECT_MESSAGES:String		= "commandDirectMessages";
		public static const COMMAND_UPDATE_LISTS:String			= "commandUpdateLists";

        /**
         * Singleton ApplicationFacade Factory Method
         */
        public static function getInstance():ApplicationFacade {
            if(instance == null)
				instance = new ApplicationFacade();
            return instance as ApplicationFacade;
        }

        /**
         * Register Commands with the Controller 
         */
        override protected function initializeController():void {
            super.initializeController(); 
            registerCommand(STARTUP, StartupCommand);
			registerCommand(COMMAND_AUTHORIZE, AuthorizeCommand);
			registerCommand(COMMAND_GRANT, GrantCommand);
			registerCommand(COMMAND_UPDATE_LISTS, UpdateListsCommand);
        }
		
		/**
		 * Start the application
		 */
		public function startup(app:Swiftair):void {
			sendNotification(STARTUP, app);
		}
		
    }
}